<template>
    <el-button size="medium" type="danger"   @click="open()">删除
        <slot></slot>
    </el-button>
</template>

<script>
    export default {
        props:['delId'] ,
        methods: {
            open() {
                this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning',
                    center: true ,
                    // beforeClose:(action, instance, done)=>{
                    //    if(action=== 'confirm'){
                    //         this.$emit('queren')
                    //        done()
                    //    }else{
                    //        done()
                    //    }
                    // }
                }).then(() => {
                    this.$axios({
                        url:'/DelArrange',
                        method:'post',
                        data:{staff_id:this.delId}
                    }).then(res=>{
                        // console.log(res)
                        if(res.status===200){
                            this.$emit('queren')
                            this.$message({
                                type: 'success',
                                message: '删除成功!',
                            });
                        }
                    }).catch(err=>{
                        this.$message({
                            type: 'error',
                            message: '删除失败，检查网络!',
                        });
                    })
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });
            }
        }
    }
</script>